import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_btn.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_btn_title.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_center_desc.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_center_title.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_dialog_close.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_dialog_left_title.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_dialog_list.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_title_desc.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_title_physical_strength.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/checkpoint/stages.dart';
import 'package:flutter_eve_plugin/pages/ye_xiu/checkpoint/actions.dart';
import 'package:flutter_eve_plugin/store/main.dart';
import 'package:flutter_eve_plugin/store_vm/app_vm.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';
import 'package:flutter_redux/flutter_redux.dart';

class CheckpointRankDialog extends Dialog {
  final String stageId;
  final CheckpointStageList item;
  CheckpointRankDialog({Key key, this.stageId, this.item}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, AppStateViewModel>(onInit: (store) {
      store.dispatch(stageInfo(stageId, context));
    }, converter: (store) {
      return AppStateViewModel(state: store.state);
    }, builder: (context, vm) {
      var info = vm.state.yeXiuState.checkpointState.checkpointStageInfo;
      var dungeonVitality = vm.state.yeXiuState.checkpointState.dungeonVitality;
      return Material(
        type: MaterialType.transparency,
        child: Padding(
          padding: EdgeInsets.only(
              top: setRatio(60),
              left: setRatio(14.5),
              right: setRatio(14.5),
              bottom: setRatio(60)),
          child: Container(
            decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [
                    Color(0xff4C4F5D),
                    Color(0xf2757C90),
                  ],
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                ),
                border:
                    Border.all(color: Color(0xFFB6BED7), width: setRatio(1)),
                borderRadius: BorderRadius.circular(setRatio(10))),
            child: CustomScrollView(
              physics: BouncingScrollPhysics(),
              slivers: <Widget>[
                SliverToBoxAdapter(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      CheckpointDialogCloseWidget(),
                      CheckpointDialogLeftTitleWidget(
                        info: info,
                        item: item,
                      ),
                      CheckpointTitleDescWidget(info: info),
                      CheckpointTitlePhysicalStrengthWidget(info: info),
                      CheckpointCenterTitleWidget(),
                      ChechpointDialogListWidget(info: info),
                      CheckpointCenterDescWidget(info: info),
                      CheckpointBtnTitleWidget(info: info),
                      CheckpointBtnWidget(info: info, dungeonVitality: dungeonVitality),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      );
    });
  }
}
